package com.sz.designpattern.construct7.flywight;

import java.util.HashMap;
import java.util.Map;

public class BigCharFactory {
    private Map<String,BigChar> pool = new HashMap();

    private BigCharFactory() {

    }

    private static BigCharFactory instance = new BigCharFactory();

    public static BigCharFactory getInstance(){
        return instance;
    }

    public synchronized BigChar getBigChar(char name){
        BigChar bigChar = pool.get(name);
        if (bigChar == null){
            bigChar = new BigChar(name);
            pool.put(name+"",bigChar);
        }
        return bigChar;
    }

    public BigChar getBigCharNotUsed(char name) {
        return new BigChar(name);
    }
}
